<HTML>
  <HEAD>
    <TITLE>threadpool Documentation</TITLE>
    <LINK HREF="threadpool.css" REL="stylesheet" TYPE="text/css">
  </HEAD>
  <BODY BGCOLOR="#FFFFFF">

    <DIV CLASS="qindex">
      <TABLE BORDER="0" WIDTH="100%">
        <TR>

          <TD ALIGN="LEFT">
            <B>threadpool</B>
          </TD>
          <TD ALIGN="RIGHT">
            <A CLASS="qindex" HREF="../index.html">Overview</A> |
            <A CLASS="qindex" HREF="../reference/annotated.html">Reference</A> |
            <A CLASS="qindex" HREF="../tutorial/intro.html">Tutorial</A> |
            <A CLASS="qindex" HREF="../examples/intro.html">Examples</A> |
            <A CLASS="qindex" HREF="../design/intro.html">Design</A>
          </TD>

        </TR>
      </TABLE>
    </DIV>
    <DIV CLASS="qindex">
      <TABLE BORDER="0" WIDTH="100%">
        <TR>
          <TD ALIGN="LEFT">
            <B>Reference</B>
          </TD>
          <TD ALIGN="RIGHT">
            <A CLASS="qindex" HREF="annotated.html">Class List</A> |
            <A CLASS="qindex" HREF="functions.html">Member Functions</A> |
            <A CLASS="qindex" HREF="namespacemembers.html">Typedefs</A> |
            <A CLASS="qindex" HREF="files.html">File List</A>
          </TD>
        </TR>
      </TABLE>
    </DIV>
<!-- Generated by Doxygen 1.4.6-NO -->
<h1>threadpool/scheduling_policies.hpp</h1><a href="a00031.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00022"></a>00022 <span class="preprocessor">#ifndef THREADPOOL_SCHEDULING_POLICIES_HPP_INCLUDED</span>
<a name="l00023"></a>00023 <span class="preprocessor"></span><span class="preprocessor">#define THREADPOOL_SCHEDULING_POLICIES_HPP_INCLUDED</span>
<a name="l00024"></a>00024 <span class="preprocessor"></span>
<a name="l00025"></a>00025 
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;queue&gt;</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include &lt;deque&gt;</span>
<a name="l00028"></a>00028 
<a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="a00034.html">task_adaptors.hpp</a>"</span>
<a name="l00030"></a>00030 
<a name="l00031"></a>00031 <span class="keyword">namespace </span>boost { <span class="keyword">namespace </span>threadpool
<a name="l00032"></a>00032 {
<a name="l00033"></a>00033 
<a name="l00044"></a>00044   <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Task = task_func&gt;  
<a name="l00045"></a><a class="code" href="a00016.html">00045</a>   <span class="keyword">class </span><a class="code" href="a00016.html">fifo_scheduler</a>
<a name="l00046"></a>00046   {
<a name="l00047"></a>00047   <span class="keyword">public</span>:
<a name="l00048"></a><a class="code" href="a00016.html#a364fa4b3952a650ce7436d338935d35">00048</a>     <span class="keyword">typedef</span> Task <a class="code" href="a00016.html#a364fa4b3952a650ce7436d338935d35">task_type</a>; 
<a name="l00049"></a>00049 
<a name="l00050"></a>00050   <span class="keyword">protected</span>:
<a name="l00051"></a><a class="code" href="a00016.html#e6582c199202df043c8d801e4cb2b50a">00051</a>     std::deque&lt;task_type&gt; <a class="code" href="a00016.html#e6582c199202df043c8d801e4cb2b50a">m_container</a>;  
<a name="l00052"></a>00052 
<a name="l00053"></a>00053 
<a name="l00054"></a>00054   <span class="keyword">public</span>:
<a name="l00059"></a><a class="code" href="a00016.html#3eb74835370fc37c8b343ecef1260973">00059</a>     <span class="keywordtype">bool</span> <a class="code" href="a00016.html#3eb74835370fc37c8b343ecef1260973">push</a>(<a class="code" href="a00016.html#a364fa4b3952a650ce7436d338935d35">task_type</a> <span class="keyword">const</span> &amp; task)
<a name="l00060"></a>00060     {
<a name="l00061"></a>00061       <a class="code" href="a00016.html#e6582c199202df043c8d801e4cb2b50a">m_container</a>.push_back(task);
<a name="l00062"></a>00062       <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00063"></a>00063     }
<a name="l00064"></a>00064 
<a name="l00067"></a><a class="code" href="a00016.html#8444283f927fbe045bb4f05b9758c2c8">00067</a>     <span class="keywordtype">void</span> <a class="code" href="a00016.html#8444283f927fbe045bb4f05b9758c2c8">pop</a>()
<a name="l00068"></a>00068     {
<a name="l00069"></a>00069       <a class="code" href="a00016.html#e6582c199202df043c8d801e4cb2b50a">m_container</a>.pop_front();
<a name="l00070"></a>00070     }
<a name="l00071"></a>00071 
<a name="l00075"></a><a class="code" href="a00016.html#b530c63c3bd816cded83df3f8cacf704">00075</a>     <a class="code" href="a00016.html#a364fa4b3952a650ce7436d338935d35">task_type</a> <span class="keyword">const</span> &amp; <a class="code" href="a00016.html#b530c63c3bd816cded83df3f8cacf704">top</a>()<span class="keyword"> const</span>
<a name="l00076"></a>00076 <span class="keyword">    </span>{
<a name="l00077"></a>00077       <span class="keywordflow">return</span> <a class="code" href="a00016.html#e6582c199202df043c8d801e4cb2b50a">m_container</a>.front();
<a name="l00078"></a>00078     }
<a name="l00079"></a>00079 
<a name="l00084"></a><a class="code" href="a00016.html#7c9a75e406bace84f39e76fead919c64">00084</a>     size_t <a class="code" href="a00016.html#7c9a75e406bace84f39e76fead919c64">size</a>()<span class="keyword"> const</span>
<a name="l00085"></a>00085 <span class="keyword">    </span>{
<a name="l00086"></a>00086       <span class="keywordflow">return</span> <a class="code" href="a00016.html#e6582c199202df043c8d801e4cb2b50a">m_container</a>.size();
<a name="l00087"></a>00087     }
<a name="l00088"></a>00088 
<a name="l00093"></a><a class="code" href="a00016.html#eac21c003c6973c7ab43b754b3a73af7">00093</a>     <span class="keywordtype">bool</span> <a class="code" href="a00016.html#eac21c003c6973c7ab43b754b3a73af7">empty</a>()<span class="keyword"> const</span>
<a name="l00094"></a>00094 <span class="keyword">    </span>{
<a name="l00095"></a>00095       <span class="keywordflow">return</span> <a class="code" href="a00016.html#e6582c199202df043c8d801e4cb2b50a">m_container</a>.empty();
<a name="l00096"></a>00096     }
<a name="l00097"></a>00097 
<a name="l00100"></a><a class="code" href="a00016.html#2173b176c9aea70f1a05015a60beb24c">00100</a>     <span class="keywordtype">void</span> <a class="code" href="a00016.html#2173b176c9aea70f1a05015a60beb24c">clear</a>()
<a name="l00101"></a>00101     {   
<a name="l00102"></a>00102       <a class="code" href="a00016.html#e6582c199202df043c8d801e4cb2b50a">m_container</a>.clear();
<a name="l00103"></a>00103     } 
<a name="l00104"></a>00104   };
<a name="l00105"></a>00105 
<a name="l00106"></a>00106 
<a name="l00107"></a>00107 
<a name="l00117"></a>00117   <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Task = task_func&gt;  
<a name="l00118"></a><a class="code" href="a00018.html">00118</a>   <span class="keyword">class </span><a class="code" href="a00018.html">lifo_scheduler</a>
<a name="l00119"></a>00119   {
<a name="l00120"></a>00120   <span class="keyword">public</span>:
<a name="l00121"></a><a class="code" href="a00018.html#932d503e02062f4aa3e9fb42d05ac2e8">00121</a>     <span class="keyword">typedef</span> Task <a class="code" href="a00018.html#932d503e02062f4aa3e9fb42d05ac2e8">task_type</a>;  
<a name="l00122"></a>00122 
<a name="l00123"></a>00123   <span class="keyword">protected</span>:
<a name="l00124"></a><a class="code" href="a00018.html#9a056bd401271660b98bc0553fb00883">00124</a>     std::deque&lt;task_type&gt; <a class="code" href="a00018.html#9a056bd401271660b98bc0553fb00883">m_container</a>;  
<a name="l00125"></a>00125 
<a name="l00126"></a>00126   <span class="keyword">public</span>:
<a name="l00131"></a><a class="code" href="a00018.html#4f9096da1dee2bc68d2e4bd1ac882178">00131</a>     <span class="keywordtype">bool</span> <a class="code" href="a00018.html#4f9096da1dee2bc68d2e4bd1ac882178">push</a>(<a class="code" href="a00018.html#932d503e02062f4aa3e9fb42d05ac2e8">task_type</a> <span class="keyword">const</span> &amp; task)
<a name="l00132"></a>00132     {
<a name="l00133"></a>00133       <a class="code" href="a00018.html#9a056bd401271660b98bc0553fb00883">m_container</a>.push_front(task);
<a name="l00134"></a>00134       <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00135"></a>00135     }
<a name="l00136"></a>00136 
<a name="l00139"></a><a class="code" href="a00018.html#f932a6f8354f9795dd5943c680fe2f42">00139</a>     <span class="keywordtype">void</span> <a class="code" href="a00018.html#f932a6f8354f9795dd5943c680fe2f42">pop</a>()
<a name="l00140"></a>00140     {
<a name="l00141"></a>00141       <a class="code" href="a00018.html#9a056bd401271660b98bc0553fb00883">m_container</a>.pop_front();
<a name="l00142"></a>00142     }
<a name="l00143"></a>00143 
<a name="l00147"></a><a class="code" href="a00018.html#5837e2157776b72e74b77ef45286c0bc">00147</a>     <a class="code" href="a00018.html#932d503e02062f4aa3e9fb42d05ac2e8">task_type</a> <span class="keyword">const</span> &amp; <a class="code" href="a00018.html#5837e2157776b72e74b77ef45286c0bc">top</a>()<span class="keyword"> const</span>
<a name="l00148"></a>00148 <span class="keyword">    </span>{
<a name="l00149"></a>00149       <span class="keywordflow">return</span> <a class="code" href="a00018.html#9a056bd401271660b98bc0553fb00883">m_container</a>.front();
<a name="l00150"></a>00150     }
<a name="l00151"></a>00151 
<a name="l00156"></a><a class="code" href="a00018.html#5dfb5c4b601a8eacb33a25f3dd1139a9">00156</a>     size_t <a class="code" href="a00018.html#5dfb5c4b601a8eacb33a25f3dd1139a9">size</a>()<span class="keyword"> const</span>
<a name="l00157"></a>00157 <span class="keyword">    </span>{
<a name="l00158"></a>00158       <span class="keywordflow">return</span> <a class="code" href="a00018.html#9a056bd401271660b98bc0553fb00883">m_container</a>.size();
<a name="l00159"></a>00159     }
<a name="l00160"></a>00160 
<a name="l00165"></a><a class="code" href="a00018.html#6d0a6ab3bd73823fe95baab9bfd1a2c9">00165</a>     <span class="keywordtype">bool</span> <a class="code" href="a00018.html#6d0a6ab3bd73823fe95baab9bfd1a2c9">empty</a>()<span class="keyword"> const</span>
<a name="l00166"></a>00166 <span class="keyword">    </span>{
<a name="l00167"></a>00167       <span class="keywordflow">return</span> <a class="code" href="a00018.html#9a056bd401271660b98bc0553fb00883">m_container</a>.empty();
<a name="l00168"></a>00168     }
<a name="l00169"></a>00169 
<a name="l00172"></a><a class="code" href="a00018.html#882e0d57368461ba48fe5cc0018b5794">00172</a>     <span class="keywordtype">void</span> <a class="code" href="a00018.html#882e0d57368461ba48fe5cc0018b5794">clear</a>()
<a name="l00173"></a>00173     {    
<a name="l00174"></a>00174       <a class="code" href="a00018.html#9a056bd401271660b98bc0553fb00883">m_container</a>.clear();
<a name="l00175"></a>00175     } 
<a name="l00176"></a>00176 
<a name="l00177"></a>00177   };
<a name="l00178"></a>00178 
<a name="l00179"></a>00179 
<a name="l00180"></a>00180 
<a name="l00192"></a>00192   <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Task = prio_task_func&gt;  
<a name="l00193"></a><a class="code" href="a00020.html">00193</a>   <span class="keyword">class </span><a class="code" href="a00020.html">prio_scheduler</a>
<a name="l00194"></a>00194   {
<a name="l00195"></a>00195   <span class="keyword">public</span>:
<a name="l00196"></a><a class="code" href="a00020.html#98e46d78da3e3755e489a90d18e69b83">00196</a>     <span class="keyword">typedef</span> Task <a class="code" href="a00020.html#98e46d78da3e3755e489a90d18e69b83">task_type</a>; 
<a name="l00197"></a>00197 
<a name="l00198"></a>00198   <span class="keyword">protected</span>:
<a name="l00199"></a><a class="code" href="a00020.html#32a5287bac7e585b01b3a30fd2585715">00199</a>     std::priority_queue&lt;task_type&gt; <a class="code" href="a00020.html#32a5287bac7e585b01b3a30fd2585715">m_container</a>;  
<a name="l00200"></a>00200 
<a name="l00201"></a>00201 
<a name="l00202"></a>00202   <span class="keyword">public</span>:
<a name="l00207"></a><a class="code" href="a00020.html#c2a0b7f1213770f1ab1e09dc404a93fb">00207</a>     <span class="keywordtype">bool</span> <a class="code" href="a00020.html#c2a0b7f1213770f1ab1e09dc404a93fb">push</a>(<a class="code" href="a00020.html#98e46d78da3e3755e489a90d18e69b83">task_type</a> <span class="keyword">const</span> &amp; task)
<a name="l00208"></a>00208     {
<a name="l00209"></a>00209       <a class="code" href="a00020.html#32a5287bac7e585b01b3a30fd2585715">m_container</a>.push(task);
<a name="l00210"></a>00210       <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00211"></a>00211     }
<a name="l00212"></a>00212 
<a name="l00215"></a><a class="code" href="a00020.html#d25be1fea45efe649c11cd3a8f21a107">00215</a>     <span class="keywordtype">void</span> <a class="code" href="a00020.html#d25be1fea45efe649c11cd3a8f21a107">pop</a>()
<a name="l00216"></a>00216     {
<a name="l00217"></a>00217       <a class="code" href="a00020.html#32a5287bac7e585b01b3a30fd2585715">m_container</a>.pop();
<a name="l00218"></a>00218     }
<a name="l00219"></a>00219 
<a name="l00223"></a><a class="code" href="a00020.html#3545e79b7450900119eb6905c197769e">00223</a>     <a class="code" href="a00020.html#98e46d78da3e3755e489a90d18e69b83">task_type</a> <span class="keyword">const</span> &amp; <a class="code" href="a00020.html#3545e79b7450900119eb6905c197769e">top</a>()<span class="keyword"> const</span>
<a name="l00224"></a>00224 <span class="keyword">    </span>{
<a name="l00225"></a>00225       <span class="keywordflow">return</span> <a class="code" href="a00020.html#32a5287bac7e585b01b3a30fd2585715">m_container</a>.top();
<a name="l00226"></a>00226     }
<a name="l00227"></a>00227 
<a name="l00232"></a><a class="code" href="a00020.html#20285a85573b5262b1417d68c4e8f486">00232</a>     size_t <a class="code" href="a00020.html#20285a85573b5262b1417d68c4e8f486">size</a>()<span class="keyword"> const</span>
<a name="l00233"></a>00233 <span class="keyword">    </span>{
<a name="l00234"></a>00234       <span class="keywordflow">return</span> <a class="code" href="a00020.html#32a5287bac7e585b01b3a30fd2585715">m_container</a>.size();
<a name="l00235"></a>00235     }
<a name="l00236"></a>00236 
<a name="l00241"></a><a class="code" href="a00020.html#18f497b423cdf0ca1216426adbbe99bc">00241</a>     <span class="keywordtype">bool</span> <a class="code" href="a00020.html#18f497b423cdf0ca1216426adbbe99bc">empty</a>()<span class="keyword"> const</span>
<a name="l00242"></a>00242 <span class="keyword">    </span>{
<a name="l00243"></a>00243       <span class="keywordflow">return</span> <a class="code" href="a00020.html#32a5287bac7e585b01b3a30fd2585715">m_container</a>.empty();
<a name="l00244"></a>00244     }
<a name="l00245"></a>00245 
<a name="l00248"></a><a class="code" href="a00020.html#0533d1d83d26c88d607f35b61254563d">00248</a>     <span class="keywordtype">void</span> <a class="code" href="a00020.html#0533d1d83d26c88d607f35b61254563d">clear</a>()
<a name="l00249"></a>00249     {    
<a name="l00250"></a>00250       <span class="keywordflow">while</span>(!<a class="code" href="a00020.html#32a5287bac7e585b01b3a30fd2585715">m_container</a>.empty())
<a name="l00251"></a>00251       {
<a name="l00252"></a>00252         <a class="code" href="a00020.html#32a5287bac7e585b01b3a30fd2585715">m_container</a>.pop();
<a name="l00253"></a>00253       }
<a name="l00254"></a>00254     } 
<a name="l00255"></a>00255   };
<a name="l00256"></a>00256 
<a name="l00257"></a>00257 
<a name="l00258"></a>00258 } } <span class="comment">// namespace boost::threadpool</span>
<a name="l00259"></a>00259 
<a name="l00260"></a>00260 
<a name="l00261"></a>00261 <span class="preprocessor">#endif // THREADPOOL_SCHEDULING_POLICIES_HPP_INCLUDED</span>
<a name="l00262"></a>00262 <span class="preprocessor"></span>
</pre></div>    <BR>
    <DIV CLASS="qindex">
      <TABLE BORDER="0" WIDTH="100%">
        <TR>
		  <TD CLASS="tiny" ALIGN="LEFT">Copyright &copy 2005-2007 Philipp Henkel</TD>
          <TD ALIGN="RIGHT">
            <A CLASS="qindex" HREF="../index.html">Overview</A> |
            <A CLASS="qindex" HREF="../reference/annotated.html">Reference</A> |
            <A CLASS="qindex" HREF="../tutorial/intro.html">Tutorial</A> |
            <A CLASS="qindex" HREF="../examples/intro.html">Examples</A> |
            <A CLASS="qindex" HREF="../design/intro.html">Design</A>
          </TD>
        </TR>       
      </TABLE>
    </DIV>  
  </BODY>
</HTML>
